//
//  TranTableViewCell.swift
//  YUANSHI
//
//  Created by pro on 2020/1/9.
//  Copyright © 2020 wangbin. All rights reserved.
//

import UIKit
import Kingfisher
class TranTableViewCell: UITableViewCell {

    var conLabel: UILabel?
    var titImage : UIImageView = {
        
        let imageView = UIImageView.init()
        return imageView
        
    }()
    
    var backScorllerView : UIScrollView = {
        let scVc = UIScrollView()
        scVc.backgroundColor = UIColor .green
        return scVc
    }()
    

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.titImage.backgroundColor = UIColor.red
        self.addSubview(self.titImage)
        self.titImage.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.height.width.equalTo(100)
        }
        
        self.conLabel = UILabel.init()
        self.conLabel?.numberOfLines = 0
        self.addSubview(self.conLabel!)
        //        self.conLabel?.text = "12312313"
        self.conLabel?.snp.makeConstraints({ (make) in
            make.bottom.left.right.equalToSuperview()
            make.top.equalTo(titImage.snp_bottom).offset(10)
        })
        //给图片添加点击事件
        addImageGesture()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    var tranModel : tranHomeModel?  {
        
        didSet{
            guard let model = tranModel else {
                return
            }
            self.conLabel?.text = model.contentInfo?.text
//            let infosModel : LBFMFindAPicInfos = model.contentInfo?.picInfos?[0] ?? 0
//                LBFMFindAPicInfos
//            self.titImage.kf.setImage(with: infosModel.originUrl as? Resource)
        }
        
    }
    
    var picModel : LBFMFindAPicInfos? {
        
        didSet{
            guard let model = picModel else {
                return
            }
            print(model.originUrl ?? "空")
            self.titImage.kf.setImage(with: URL(string: model.originUrl!))
        }
        
    }
    
    
    
    
    
}

extension TranTableViewCell {
    
    func addImageGesture() {
        self.titImage.isUserInteractionEnabled = true
        
        self.titImage.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imageViewGestureEven)))
        
    }
    
    @objc func imageViewGestureEven(){
        
    }
    
}
